SYS.VimuaMenu = SYS.extend(SYS.Module,{
	defaultVal:'laptop',
	init:function(success){
		var that = this;
		SYS.Module.prototype.init.call(that,success);
	},
	initEvents:function(categoryId){
		var that = this;
		//Exec
		if (categoryId==undefined) {
			switch(SYS.request('page')){
				case 'product_detail':
				case 'product_list':
				case 'product_compare':
				case 'search':
					var categoryId = SYS.request('category_id');
					if(categoryId){
						that.defaultVal = categoryId;
					}
					break;
				default:
					if(SYS.request('page') && !/[^\w]/.test(SYS.request('page'))){
						that.defaultVal = 'laptop';
					}
					break;
			}
		} else {
			that.defaultVal = categoryId;
		}
		var isSubMenu = false;
		$('#menu div.menu_con a').each(function(i){
			if (this.oldclick==undefined) this.oldclick = this.onclick;
			if($(this).attr('class') == 'text_bigdart') {
				this.putfocus = function(val, ani, abc) {
					var thisParent = $(this).parent().parent();
					if (val==true) {
						var xheight = thisParent.find('ul > li').length;
						xheight = xheight * 22 + 20;
						var node1 = thisParent.children('.menucon_muiten');
						if (node1) {
							node1.removeClass('menucon_muiten');
							node1.addClass('menucon_titon');
						}
						thisParent.find('.menucon_titon img:first').hide();
						thisParent.animate( { height:xheight + "px" }, ani?300:0 );
						//document.activeMenu=this;
					} else {
						var node1 = thisParent.children('.menucon_titon');
						if (node1) {
							node1.removeClass('menucon_titon');
							node1.addClass('menucon_muiten');
						}
						thisParent.find('.menucon_muiten img:first').show();
						if (ani) {
							thisParent.animate( { height:"22px" }, 300 );
						} else {
							if (thisParent.css('height')!='22px') {
								thisParent.css( { height:"22px" } );
							}
						}
					}
				}
				this.onclick = function() {
					//try {if(undefined!=document.activeSubMenu) document.activeSubMenu.putfocus(false); document.activeSubMenu=undefined;} catch (e) {}
					/*
					if(undefined!=document.activeMenu && document.activeMenu!=this) {
						//document.activeMenu.putfocus(false, true, 'chuoi');
						//this.putfocus(true, true);
					}
					*/
					if (this.oldclick!=undefined) this.oldclick();
					return false;
				}
			}
			if($(this).attr('class') == 'text_path'){ // Click Menu cap 2
				this.putfocus = function(val) {
					if (val==true) {
						isSubMenu = true;
						$(this).css({'color':'#CC0000','font-weight':'bold'});
						//document.activeSubMenu = this;
						var thisParent = $(this).parent().parent().parent().parent().find('a:first').get(0);
						thisParent.putfocus(true, false);
						//document.activeMenu = thisParent;
						//document.activeMenu.innerHTML = '';
					} else {
						$(this).css({'color':'black','font-weight':'normal'});
					}
				}
				this.putfocus(($(this).attr('id') == 'menuitem_'+that.defaultVal));
				this.onclick = function() {
					try {
						//if (undefined!=document.activeSubMenu) document.activeSubMenu.putfocus(false);
					} catch (e) {}
					this.putfocus(true);
					if (this.oldclick!=undefined) this.oldclick();
					return false;
				}
			}
		});
		if (isSubMenu==false) {
			$('#menu div.menu_con a').each(function(i){
				if($(this).attr('class') == 'text_bigdart') {
					this.putfocus($(this).attr('id') == 'menuitem_'+that.defaultVal, false); // Click Menu cap 1
				}});
		}
	},
	closeAll:function(){
		$('#menu > div.menu_con').each(function (){
		   $(this).css({height:"20px"});
        });
	}
});